import os

from django.conf import settings
from celery import Celery
# from celery.schedules import crontab

os.environ.setdefault(
    'DJANGO_SETTINGS_MODULE',
    'yuncoding.settings'
)

app = Celery('yuncoding')


class CeleryConfig(object):
    broker_url = settings.CELERY_BROKER_REDIS_URL
    result_backend = settings.CELERY_RESULT_BACKEND_REDIS_URL
    timezone = 'Asia/Shanghai'

    task_routes = {
        'account.tasks.*': {'queue': 'account'},
    }

    beat_schedule = {}


app.config_from_object(CeleryConfig)
app.autodiscover_tasks(
    lambda: settings.INSTALLED_APPS + ['yuncoding']
)
